package com.csaba.swing.gui.wizard;

import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;

@SuppressWarnings( "serial" )
public class WizardHeader extends JPanel
{

	private String title = " "; //$NON-NLS-1$
	private String description = " "; //$NON-NLS-1$
	private String message = " "; //$NON-NLS-1$

	private ImageIcon icon;
	private JLabel titleLabel;
	private JLabel descriptionLabel;
	private JLabel messageLabel;
	private JLabel imagePanel;

	public WizardHeader( final String title, final String description )
	{
		super(new BorderLayout(5, 10));
		this.title = title;
		this.description = description;

		initUI();
	}

	private void initUI()
	{
		setBackground(Color.white);
		setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10));

		titleLabel = new JLabel(title);
		titleLabel.setOpaque(false);

		descriptionLabel = new JLabel(description);
		descriptionLabel.setOpaque(false);

		messageLabel = new JLabel(message);
		messageLabel.setOpaque(false);

		final JPanel messagePanel = new JPanel(new BorderLayout(10, 10));
		messagePanel.setOpaque(false);
		messagePanel.add(titleLabel, BorderLayout.NORTH);
		messagePanel.add(descriptionLabel, BorderLayout.CENTER);
		final JSeparator sep = new JSeparator(JSeparator.VERTICAL);
		sep.setForeground(Color.white);
		messagePanel.add(sep, BorderLayout.WEST);
		messagePanel.add(messageLabel, BorderLayout.SOUTH);

		imagePanel = new JLabel();
		if ( icon != null )
			imagePanel.setIcon(icon);

		add(messagePanel, BorderLayout.CENTER);
		add(imagePanel, BorderLayout.EAST);

	}

	public void setTitle( final String title )
	{
		this.title = title;
		titleLabel.setText(title);
	}

	public String getTitle()
	{
		return title;
	}

	public void setDescription( final String description )
	{
		this.description = description;
		descriptionLabel.setText(description);
	}

	public String getDescription()
	{
		return description;
	}

	public void setMessage( final String message )
	{
		this.message = message;
		messageLabel.setText(message);
	}

	public String getMessage()
	{
		return message;
	}

	public void setIcon( final ImageIcon icon )
	{
		this.icon = icon;
		imagePanel.setIcon(icon);
	}

	public ImageIcon getIcon()
	{
		return icon;
	}

	public void clearMessage()
	{
		messageLabel.setText(" "); //$NON-NLS-1$

	}
}
